﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OF.Utility;

namespace OF.Component.DTO
{
    public class PostDetailDto
    {
        /// <summary>
        /// 动态类型，1：发单，2：接单
        /// </summary>
        public int PostType { get; set; }
        /// <summary>
        /// 动态ID
        /// </summary>
        public int PostID { get; set; }
        
        /// <summary>
        /// 价格
        /// </summary>
        public double PersonPrice { get; set; }

        /// <summary>
        /// 动态内容
        /// </summary>
        public string Content { get; set; }

        /// <summary>
        /// 发布时间
        /// </summary>
        public DateTime CreatedDate { get; set; }

        /// <summary>
        /// 店铺名称
        /// </summary>
        public string ShopName { get; set; }

        /// <summary>
        /// 用户名
        /// </summary>
        public string UserName { get; set; }

        /// <summary>
        /// 手机号
        /// </summary>
        public string Mobile { get; set; }

        /// <summary>
        /// 业务类型名
        /// </summary>
        public string BizTypeName { get; set; }

        /// <summary>
        /// 城市
        /// </summary>
        public string LocationName { get; set; }

        /// <summary>
        /// 动态图
        /// </summary>
        public List<string> PostImgList { get; set; }

        /// <summary>
        /// 点赞人
        /// </summary>
        public List<PostDetailLikeUserDto> LikeUser { get; set; }

        /// <summary>
        /// 评论信息
        /// </summary>
        public List<PostDetailCommentDto> CommentInfo { get; set; }

        /// <summary>
        /// 显示时间
        /// </summary>
        public string ShowTime {
            get {
                string st = "";
                TimeSpan ts = DateTime.Now - CreatedDate;
                //if (ts.Minutes<60)
                //{
                //    st = string.Format("{0}分钟前",ts.Minutes);
                //}
                //if (ts.Hours >= 1 && ts.Hours < 24)
                //{
                //    st = string.Format("{0}小时前", ts.Hours);
                //}
                //if (ts.Hours >= 24 && ts.Hours < 48)
                //{
                //    st = "昨天";
                //}
                //if (ts.Hours >= 48)
                //{
                //    st = string.Format("{0}天前", ts.Hours);
                //}
                if (ts.TotalMinutes < 60)
                {
                    st = string.Format("{0}分钟前", EConvert.ToInt(ts.TotalMinutes));
                }
                if (ts.TotalMinutes > 60 && ts.TotalMinutes < 24*60)
                {
                    //st = string.Format("{0}小时前", EConvert.ToInt(ts.TotalMinutes / 60));
                    st = string.Format("{0}小时前", ts.Hours);
                }
                if (ts.TotalMinutes >= 24*60 && ts.TotalMinutes < 48*60)
                {
                    st = "昨天";
                }
                if (ts.TotalMinutes >= 48*60)
                {
                    //st = string.Format("{0}天前", EConvert.ToInt(ts.TotalMinutes/(60*24)));
                    st = string.Format("{0}天前", ts.Days);
                }
                return st;
            }
        }
        /// <summary>
        /// 1：引用微信，2：用户上传
        /// </summary>
        public int HeadImgSrcType { get; set; }
        /// <summary>
        /// 头像
        /// </summary>
        public string HeadImgSrc { get; set; }

        /// <summary>
        /// 发布动态店铺
        /// </summary>
        public int ShopID { set; get; }

    }

    public class PostDetailLikeUserDto
    {
        /// <summary>
        /// 店铺ID
        /// </summary>
        public int ShopID { get; set; }
        /// <summary>
        /// 用户名称
        /// </summary>
        public string UserName { get; set; }
        /// <summary>
        /// 店铺名称
        /// </summary>
        public string ShopName { get; set; }

    }

    public class PostDetailCommentDto
    {
        /// <summary>
        /// 店铺ID
        /// </summary>
        public int ShopID { get; set; }
        /// <summary>
        /// 用户名称
        /// </summary>
        public string UserName { get; set; }
        /// <summary>
        /// 店铺名称
        /// </summary>
        public string ShopName { get; set; }
        /// <summary>
        /// 评论内容
        /// </summary>
        public string Content { get; set; }
    }
}
